/*
 * Copyright (C) 2016 The Android Open Source Project
 *  Created by  Ant  2016/9/5  14:57
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.ant.cn.app;

import android.app.Activity;
import android.app.Application;

import com.ant.cn.utils.AntLog;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by baichuan on 2016/9/5.
 */
public class App extends Application {
    public static String TAG = "app";

    public static List<Activity> list;


    @Override
    public void onCreate() {
        super.onCreate();
    }


    public static void addActivity(Activity ac) {
        AntLog.i(TAG, ac.getClass().getSimpleName());
        if (list == null) {
            list = new ArrayList<>();
        }
        list.add(ac);
    }

    public static void exit() {
        if (list == null)
            return;

        for (Activity ac : list) {
            ac.finish();
        }
    }

    public static void remove(Activity ac) {
        if (list == null)
            return;
        AntLog.i(TAG,ac.getClass().getName());
        list.remove(ac);
    }
}
